package com.atguigu.principle.inversion.improve;

/**
 * @author ccc
 * @create 2020-07-09 15:22
 */
public class DependencyPassOfInterface {
    public static void main(String[] args) {
        ITV tv = new ChangHongTV();

        OpenAndClose openAndClose = new OpenAndClose();
        openAndClose.open(tv);
    }
}

//方式1，通过接口传递实现依赖
//开关的接口
interface IOpenAndClose{
    public void open(ITV tv); //抽象方法，接收接口
}
interface ITV { //ITV 接口 用来搞具体电视类型 长虹之类的
    public void play();
}
class ChangHongTV implements ITV{ //使用长虹电视来举例
    @Override
    public void play() {
        System.out.println("长虹电视开机");
    }
}
//实现接口
class OpenAndClose implements IOpenAndClose{
    @Override
    public void open(ITV tv) {
        tv.play();
    }
}
